package com.klw.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.klw.common.annotation.Log;
import com.klw.common.core.controller.BaseController;
import com.klw.common.core.domain.AjaxResult;
import com.klw.common.enums.BusinessType;
import com.klw.business.domain.KlwScores;
import com.klw.business.service.IKlwScoresService;
import com.klw.common.utils.poi.ExcelUtil;
import com.klw.common.core.page.TableDataInfo;

/**
 * 学生成绩Controller
 * 
 * @author klw
 * @date 2025-08-24
 */
@RestController
@RequestMapping("/core/scores")
public class KlwScoresController extends BaseController
{
    @Autowired
    private IKlwScoresService klwScoresService;

    /**
     * 查询学生成绩列表
     */
    @PreAuthorize("@ss.hasPermi('core:scores:list')")
    @GetMapping("/list")
    public TableDataInfo list(KlwScores klwScores)
    {
        startPage();
        List<KlwScores> list = klwScoresService.selectKlwScoresList(klwScores);
        return getDataTable(list);
    }

    /**
     * 导出学生成绩列表
     */
    @PreAuthorize("@ss.hasPermi('core:scores:export')")
    @Log(title = "学生成绩", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, KlwScores klwScores)
    {
        List<KlwScores> list = klwScoresService.selectKlwScoresList(klwScores);
        ExcelUtil<KlwScores> util = new ExcelUtil<KlwScores>(KlwScores.class);
        util.exportExcel(response, list, "学生成绩数据");
    }

    /**
     * 获取学生成绩详细信息
     */
    @PreAuthorize("@ss.hasPermi('core:scores:query')")
    @GetMapping(value = "/{scoreId}")
    public AjaxResult getInfo(@PathVariable("scoreId") Long scoreId)
    {
        return success(klwScoresService.selectKlwScoresByScoreId(scoreId));
    }

    /**
     * 新增学生成绩
     */
    @PreAuthorize("@ss.hasPermi('core:scores:add')")
    @Log(title = "学生成绩", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody KlwScores klwScores)
    {
        return toAjax(klwScoresService.insertKlwScores(klwScores));
    }

    /**
     * 修改学生成绩
     */
    @PreAuthorize("@ss.hasPermi('core:scores:edit')")
    @Log(title = "学生成绩", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody KlwScores klwScores)
    {
        return toAjax(klwScoresService.updateKlwScores(klwScores));
    }

    /**
     * 删除学生成绩
     */
    @PreAuthorize("@ss.hasPermi('core:scores:remove')")
    @Log(title = "学生成绩", businessType = BusinessType.DELETE)
	@DeleteMapping("/{scoreIds}")
    public AjaxResult remove(@PathVariable Long[] scoreIds)
    {
        return toAjax(klwScoresService.deleteKlwScoresByScoreIds(scoreIds));
    }
}
